<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<div style="padding: 15px">
    <form class="layui-form" action="" th:object="${user}">
        <input name="userId" type="hidden" th:field="*{userId}"/>
        <input name="deptId" type="hidden" th:field="*{deptId}" id="treeId"/>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                    <input type="text" th:field="*{userName}" name="userName" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">登录名</label>
                <div class="layui-input-inline">
                    <input type="text" th:field="*{loginName}" name="loginName" lay-verify="required" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">所在部门</label>
                <div class="layui-input-inline">
                    <input class="layui-input" type="text" onclick="selectDeptTree()" id="treeName" readonly="true"
                           name="deptName"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">手机号码</label>
                <div class="layui-input-inline">
                    <input type="text" th:field="*{phonenumber}" name="phonenumber" lay-verify="required|phone"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="email" th:field="*{email}" name="email" lay-verify="required|email" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-inline">
                    <select name="sex" id="sex" lay-verify="required" lay-search="">
                        <option value="1" th:field="*{sex}">男</option>
                        <option value="2" th:field="*{sex}">女</option>
                        <option value="2" th:field="*{sex}">不确定</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">账号状态</label>
                <div class="layui-input-inline">
                    <select name="status" id="status" lay-verify="required" lay-search="">
                        <option value="0" th:field="*{status}">正常</option>
                        <option value="1" th:field="*{status}">禁用</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <input name="role" type="checkbox" th:each="role:${roles}" th:value="${role.roleId}" th:title="${role.roleName}"
                       th:checked="${role.flag}" th:disabled="${role.status == '1'}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="user">修改保存</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    /*<![CDATA[*/
    var sysUrl = '/venus/system/user';
    layui.use(['form'], function () {
        var form = layui.form;

        form.on('submit(user)', function (data) {
            data.field.roleIds= selectCheckeds("role");
            save(sysUrl, 'edit', data.field);
            return false;
        });
    });
    /*]]>*/
</script>
</body>
</html>